do "E:/ReplicateBuild/02_code/00_environment/00_set_environment.do"

use "$temp/student_level_ma_w_unshrunken_VA", clear

keep DISAD mastid year
bys mastid: egen nobs = count(DISAD)
bys mastid: egen nDISAD = sum(DISAD)

bys nobs: tab nDISAD if year==2016 & DISAD==1

gen alwaysDISAD = nDISAD==nobs

forv a=1/4 {
summ alwaysDISAD if year==2016 & DISAD==1 & nobs==`a'
global a`a' = r(mean)
}
summ alwaysDISAD if year==2016 & DISAD==1 & nobs>=5
global a5 = r(mean)

forv a=1/5 {
	mat a`a' = (${a`a'})
	gen a`a'var = .
}
forv a=1/4 {
	label var a`a'var "Students appearing `a' times"
}
label var a5var "Students appearing at least 5 times"

forv i=1/5 {
    mat rownames a`i' = a`i'var
}

mat a = a1\a2\a3\a4\a5

frmttable using "$tables/DISAD_persistence", statmat(a) replace va tex fra ///
	ctitles("","Fraction of current disadvantaged students always disadvantaged") ///
	sdec(2\2\2\2\2) 